package com.carpedil.smvc.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carpedil.smvc.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/** @author Administrator */
@Repository("userMapper")
public interface UserMapper extends BaseMapper<User> {
  /**
   * getUsersByPageParam
   *
   * @param page page
   * @param wrapper wrapper
   * @return IPage<User>
   */
  @Select(
      "select * "
          + " from user_role ur "
          + " inner join users u on u.id = ur.fk_user_id "
          + " inner join roles r on r.pk_id = ur.fk_role_id ${ew.customSqlSegment}")
  @ResultMap("com.carpedil.smvc.dao.UserMapper.userMap")
  IPage<User> getUsersByPageParam(Page<User> page, @Param(Constants.WRAPPER) Wrapper<User> wrapper);
}
